home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Aol / aol-unsorted / AOLHeaderStrip.pl.sit / AOLHeaderStrip.pl.rsrc / TEXT_128_!.txt < prev    next >
Text File  |  1997-11-29  |  2KB  |  36 lines

  1. # This script reads in an AOL text mail file and strips of the "headers"
  2. # at the end of the file which tend to confuse some file viewers.
  3. # Written by William Cameron, 29 Nov 1997.
  4. # Requires MacPerl by Matthias Neeracher and Tim Endres
  5. # This is what precedes the headers in AOL mail files.
  6. $header = "----------------------- Headers --------------------------------\n";
  7. $index = 0; # this variable used to address each filename in @ARGV
  8. # For each of the files dropped on this droplet do the following:
  9. # read in a line
  10. # check to see if it is the AOL Header line
  11. # if not, write the line to a file of the same name on the desktop
  12. # if it does match, close the input and output files, and get the next file
  13. while ($ARGV[$index]){
  14.     $infile = $ARGV[$index];
  15.     @path = split(/:/, $infile);
  16.     open (IN, "$infile");
  17.     # THE NEXT THREE LINES ARE NO LONGER APPLIED--not general enough
  18.     # Match up to the last 31 characters following a colon--this is the file name.
  19.     # Replace the path with the destination path as coded.
  20.     #    $outfile =~ s/.+:([ -9;-~]{1,31})$/Kermie 234:Desktop Folder:$1/;
  21.     #
  22.     # Instead, we do it this way.
  23.     # $path[0] is the name of the drive the files were on
  24.     # $#path is the index of the last element of the array @path,
  25.     # so $path[$#path] is the name of the file.
  26.     $outfile = $path[0] . ':' . 'Desktop Folder' . ':' . $path[$#path];
  27.     open(OUT, ">>$outfile");
  28.     MacPerl::SetFileInfo('R*ch', 'TEXT', $outfile);
  29.     while ($line = <IN>) {
  30.         last if ($line eq $header);
  31.         print OUT $line;
  32.     }
  33.     close (IN);
  34.     close (OUT);
  35.     $index++;
  36. }